package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.*;

import java.util.Date;
import java.util.HashMap;


@Setter
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class StrategyDetail extends BaseDomain{

    public static final Integer STATE_RELEASE = 0; //发布
    public static final Integer STATE_TEMP = 1; //草稿

    private String title;
    //创建时间
    private Date createTime;
    //发布时间
    private Date releaseTime;
    //序列
    private Integer sequence;

    private String coverUrl;

    private Integer state=STATE_RELEASE;


    //攻略分类
    private StrategyCatalog catalog;

    //攻略文章内容
    private StrategyContent strategyContent;


    public String getStateName() {
        return state==STATE_RELEASE? "发布" : "草稿";
    }


    public String getJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        map.put("strategyId", catalog.getStrategyId());
        map.put("catalogId", catalog.getId());
        map.put("sequence", sequence);
        map.put("state", state);
        return JSONUtil.toJSONString(map);
    }


}